import requests

from com.yh.oa.utils.utils import oahost


class Job():

    def queryJobList(self,pageNum=1,pageSize=10,postCode="",postName="",status="",token=""):
        params = {
            "pageNum":pageNum,
        "pageSize":pageSize,
        "postCode":postCode,
        "postName":postName,
        "status":status

        }

        resp = requests.get(oahost+"/system/post/list",params=params,headers=token)
        return resp

    def addJob(self,postCode,postName,postSort,status,token):
        list = {
            "postCode":postCode,
            "postName":postName,
            "postSort":postSort,
            "status":status
        }
        resp = requests.post(oahost+"/system/post",json=list,headers=token)
        return resp

    def updateJob(self,postCode,postName,postSort,status,token):
        list = {
            "postCode": postCode,
            "postName": postName,
            "postSort": postSort,
            "status": status
        }
        resp = requests.put(oahost + "/system/post", json=list, headers=token)
        return resp

    def exportExcel(self,pageNum,pageSize,token):
        params = {
            "pageNum": pageNum,
            "pageSize": pageSize
        }
        resp = requests.get(oahost+"/system/post/export",params=params,headers=token)
        return resp

    def jobId(self,postId,token):
        params = {
            "postId": postId
        }
        resp = requests.get(oahost+"/system/post/{}".format(params),headers=token)
        return resp
